/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package kimo.persistence.entities;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author a381u296
 */
@Entity
@Table(name = "production")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Production.findAll", query = "SELECT p FROM Production p"),
    @NamedQuery(name = "Production.findByProductionId", query = "SELECT p FROM Production p WHERE p.productionId = :productionId"),
    @NamedQuery(name = "Production.findByProductionYear", query = "SELECT p FROM Production p WHERE p.productionYear = :productionYear"),
    @NamedQuery(name = "Production.findByProductionFarmOsde", query = "SELECT p FROM Production p WHERE p.productionFarmOsde = :productionFarmOsde"),
    @NamedQuery(name = "Production.findByProductionFarmArea", query = "SELECT p FROM Production p WHERE p.productionFarmArea = :productionFarmArea"),
    @NamedQuery(name = "Production.findByProductionRawProductKilos", query = "SELECT p FROM Production p WHERE p.productionRawProductKilos = :productionRawProductKilos"),
    @NamedQuery(name = "Production.findByProductionProductKilos", query = "SELECT p FROM Production p WHERE p.productionProductKilos = :productionProductKilos")})
public class Production implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "production_id")
    private Integer productionId;
    @Basic(optional = false)
    @Column(name = "production_year")
    @Temporal(TemporalType.DATE)
    private Date productionYear;
    @Column(name = "production_farm_osde")
    private String productionFarmOsde;
    @Basic(optional = false)
    @Column(name = "production_farm_area")
    private double productionFarmArea;
    @Basic(optional = false)
    @Column(name = "production_raw_product_kilos")
    private double productionRawProductKilos;
    @Basic(optional = false)
    @Column(name = "production_product_kilos")
    private double productionProductKilos;
    @JoinColumn(name = "production_raw_product_id", referencedColumnName = "raw_product_id")
    @ManyToOne(optional = false)
    private RawProduct productionRawProductId;
    @JoinColumn(name = "production_product_id", referencedColumnName = "product_id")
    @ManyToOne(optional = false)
    private Product productionProductId;
    @JoinColumn(name = "production_producer_id", referencedColumnName = "producer_id")
    @ManyToOne(optional = false)
    private Producer productionProducerId;

    public Production() {
    }

    public Production(Integer productionId) {
        this.productionId = productionId;
    }

    public Production(Integer productionId, Date productionYear, double productionFarmArea, double productionRawProductKilos, double productionProductKilos) {
        this.productionId = productionId;
        this.productionYear = productionYear;
        this.productionFarmArea = productionFarmArea;
        this.productionRawProductKilos = productionRawProductKilos;
        this.productionProductKilos = productionProductKilos;
    }

    public Integer getProductionId() {
        return productionId;
    }

    public void setProductionId(Integer productionId) {
        this.productionId = productionId;
    }

    public Date getProductionYear() {
        return productionYear;
    }

    public void setProductionYear(Date productionYear) {
        this.productionYear = productionYear;
    }

    public String getProductionFarmOsde() {
        return productionFarmOsde;
    }

    public void setProductionFarmOsde(String productionFarmOsde) {
        this.productionFarmOsde = productionFarmOsde;
    }

    public double getProductionFarmArea() {
        return productionFarmArea;
    }

    public void setProductionFarmArea(double productionFarmArea) {
        this.productionFarmArea = productionFarmArea;
    }

    public double getProductionRawProductKilos() {
        return productionRawProductKilos;
    }

    public void setProductionRawProductKilos(double productionRawProductKilos) {
        this.productionRawProductKilos = productionRawProductKilos;
    }

    public double getProductionProductKilos() {
        return productionProductKilos;
    }

    public void setProductionProductKilos(double productionProductKilos) {
        this.productionProductKilos = productionProductKilos;
    }

    public RawProduct getProductionRawProductId() {
        return productionRawProductId;
    }

    public void setProductionRawProductId(RawProduct productionRawProductId) {
        this.productionRawProductId = productionRawProductId;
    }

    public Product getProductionProductId() {
        return productionProductId;
    }

    public void setProductionProductId(Product productionProductId) {
        this.productionProductId = productionProductId;
    }

    public Producer getProductionProducerId() {
        return productionProducerId;
    }

    public void setProductionProducerId(Producer productionProducerId) {
        this.productionProducerId = productionProducerId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (productionId != null ? productionId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Production)) {
            return false;
        }
        Production other = (Production) object;
        if ((this.productionId == null && other.productionId != null) || (this.productionId != null && !this.productionId.equals(other.productionId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "kimo.persistence.entities.Production[ productionId=" + productionId + " ]";
    }
    
    public RawProductType getProductionRawProductTypeId() {
        return this.productionRawProductId.getRawProductTypeId();
    }

    public ProductCategory getProductionProductCategoryId() {
        return this.productionProductId.getProductTypeId().getProductTypeCategoryId();
    }

    public ProductType getProductionProductTypeId() {
        return this.productionProductId.getProductTypeId();
    }
    
}
